/**
 * defalut config(development)
 */

module.exports = appInfo => {
  const config = exports = {};
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1512026752193_6152';
  // add your config here
  config.middleware = [ 'notfoundHandler' ];
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: '172.20.3.53', // Redis host
      db: 0,
      password: '',
    },
  };
  config.mongoose = {
    url: 'mongodb://172.20.3.53:27017/yea',
    option: {},
  };
  // config.rbac = {
  //   /**
  //        * @param {object} ctx - egg context object
  //        * @return {object} promise, if resolve data is falsy, no role
  //        */
  //   * getRoleName(ctx) {
  //     ctx.body = '';
  //     return Promise.resolve('');
  //   },
  // };

  config.userservice = {
    service: {
      async getUser(ctx) {
        await {};
        // Retrieve your user data from cookie, redis, db, whatever
        // For common web applications using cookie, you may get session id with ctx.cookies
      },
      getUserId(ctx) {
        ctx.user = {
          userId: 1,
        };
        return ctx.user.userId;
        // The way to get userId
        // eg. return ctx.user.userId
      },
    },
  };
  config.static = {
    prefix: '/',
  };
  return config;
};
